<script src="<?php echo base_url("assets/js/jquery.slugify.js")?>"></script>
<style>
	label{font-weight:bold}
	.btn-back{margin-left:15px;}
</style>
<script>
$().ready(function(){
	generate_slug = function(input_form, output_form, space_character, disallow_dashes){
		space_character = space_character || '-';
		$(input_form).slugify({ slug: output_form, type: space_character });
	} 
	$("input[name='title']").on("keyup",function(e) {
		generate_slug($(this), $('#slug'));
	});
	$("#delete_img, #delete_img2").click(function(){
		if(confirm("Bạn có thật sự muốn xóa hình này")){
			return true;	
		}
		return false;
	});
	$(".btn-back").click(function(){
		window.location = "<?php echo site_url("admin/news")?>";
		return false;
	});
}); 
</script>
<div class="page-header">
	<h1>Comment <?php echo empty($model["title"])?"":$model["title"]?></h1>
</div>
<?php echo form_open_multipart($this->config->item('admin_folder').'/news/edit/'.$model["id"]); ?>
<div class="tabbable">
    <div class="tab-content">
    	<div class="form-actions"><button class="btn btn-primary">Lưu</button> <button class="btn btn-back">Trở về</button></div>
        <fieldset>
            <label for="name">Khách hàng</label>
            <?php echo form_input(array("name"=>"title","value"=>$model["title"],"class"=>"span12","id"=>"title")) ?>
            <label for="name">Liên kết tĩnh</label>
             <?php echo form_input(array("name"=>"slug","value"=>$model["slug"],"class"=>"span12","id"=>"slug","readonly"=>"readonly")) ?>
             <?php if(!empty($category)){echo '<label> Danh mục tin </label>'; 
					 echo form_dropdown("cat_id",$category,$model["cat_id"],"class='span4'");
			 }?>
             <label for="status"> Trạng thái</label>
             <?php echo form_dropdown("active",array(1=>"bật",2=>"tắt"),$model["active"],"class='span4'")?>
              <label for="status">Tin nổi bật</label>
             <?php echo form_dropdown("active_highlights",array(1=>"bật",2=>"tắt"),$model["active_highlights"],"class='span4'")?>
            <label> Hình ảnh <span><i> (width: 170px, height: 67px)</i></span></label>
            <input type="file" name="file" />
            <?php if(!empty($model["image"])){?>
            	<img src="<?php echo base_url("uploads/images/thumbnails/news/".$model["image"])?>" />
                <a id="delete_img" href="<?php echo site_url("admin/news/delete_img/".$model["id"]) ?>">xóa ảnh</a>
            <?php }?>
            <label> Hình ảnh lớn <span><i> (width:700px)</i></span></label>
            <input type="file" name="file2" />
            <?php if(!empty($model["image2"])){?>
            	<img src="<?php echo base_url("uploads/images/thumbnails/news/".$model["image2"])?>" />
                <a id="delete_img2" href="<?php echo site_url("admin/news/delete_img/".$model["id"]."/1/1") ?>">xóa ảnh</a>
            <?php }?>
            <label for="name">tags</label>
            <?php $i=0; if(!empty($tag_name)) foreach($tag_name as $item){ if($i!=0) $tags .= ",";$tags .= $item->name;$i=1;}?>
            <?php echo form_input(array("name"=>"tags","value"=>$tags,"class"=>"span12","id"=>"tags")) ?>
             <label style="margin-top:10px"> Mô tả ngắn </label>
            <?php echo form_textarea(array("name"=>"description","value"=>$model["description"],"class"=>"span12")) ?>
            <label> Nội dung </label>
            <?php //echo form_textarea(array("name"=>"bodyhtml","value"=>html_entity_decode($model["bodyhtml"]),"class"=>"redactor","cols"=>40,"rows"=>10)) ?>
            <?php echo form_textarea(array("name"=>"bodyhtml","value"=>$model["bodyhtml"],"class"=>"redactor","cols"=>40,"rows"=>10)) ?>
        </fieldset>
        <fieldset>
        	<label>Meta Keyword</label>
            <?php echo form_input(array("name"=>"keywords","value"=>$model["keywords"]))?>
        </fieldset>
        <div class="form-actions"><button class="btn btn-primary">Lưu</button> <button class="btn btn-back">Trở về</button></div>
    </div>
</div>